home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-07-28 | 4.0 KB | 169 lines | [TEXT/MPS ] |
- /*
- File: 2020RecipientReport.cp
-
- Copyright: © 1991-1994 by Apple Computer, Inc.
- All rights reserved.
-
- Part of the AOCE Sample SMSAM Package. Consult the license
- which came with this software for your specific legal rights.
-
- */
-
-
-
-
- #ifndef __BLJSTANDARDINCLUDES__
- #include "BLJStandardIncludes.h"
- #endif
-
- #ifndef __2020RECIPIENTREPORT__
- #include "2020RecipientReport.h"
- #endif
-
- #ifndef __AYSTHREADGLUE__
- #include "AYSThreadGlue.h"
- #endif
-
- #ifndef __MAILBUFFER__
- #include "MailBuffer.h"
- #endif
-
- #ifndef __DEBUGGINGGEAR__
- #include "DebuggingGear.h"
- #endif
-
- #ifndef __BLJOCEUTILITIES__
- #include "BLJOCEUtilities.h"
- #endif
-
- #ifndef __UTILITIES__
- #include "Utilities.h"
- #endif
-
-
- T2020RecipientReport::T2020RecipientReport(long queueID, long sequenceNumber) {
-
- // Open up the recipient report, extract all of it's information into our own fields,
- // and then close the recipient report.
-
- fQueueID = queueID;
- fSequenceNumber = sequenceNumber;
-
- fRecipientReportCount = 0;
- fRecipientReport = nil;
-
- TRY
- {
- MSAMOpenPB openPB;
- memset(&openPB, 0, sizeof(openPB));
-
- openPB.queueRef = queueID;
- openPB.seqNum = sequenceNumber;
-
- FAILOSErr(MSAMOpenSleep((MSAMParam*) &openPB));
-
- MSAMGetBlockPB getBlockPB;
-
- TRY
- {
- getBlockPB.mailMsgRef = openPB.mailMsgRef;
- getBlockPB.blockType.msgCreator = kIPMSignature;
- getBlockPB.blockType.msgType = kMailReportType;
- getBlockPB.blockIndex = 1;
- getBlockPB.buffer = AllocateMailBuffer(0, 0);
- getBlockPB.dataOffset = 0;
- FAILOSErr(MSAMGetBlockSleep((MSAMParam*) &getBlockPB));
- DisposeMailBuffer ( getBlockPB.buffer );
-
- // Allocate a handle into which we'll read the contents of this block.
- fRecipientReport = FAILNewHandle(getBlockPB.remaining);
-
- // Now, lock our data handle and read the complete contents of the report block into
- // this data handle.
- HLock(fRecipientReport);
-
- getBlockPB.buffer = AllocateMailBuffer(GetHandleSize(fRecipientReport), *fRecipientReport);
- getBlockPB.dataOffset = 0;
- FAILOSErr(MSAMGetBlockSleep((MSAMParam*) &getBlockPB));
-
- HUnlock(fRecipientReport);
-
- // Lastly, calculate how many recipient reports are in this report
- fRecipientReportCount = (GetHandleSize(fRecipientReport) - sizeof(IPMReportBlockHeader)) / sizeof(OCERecipientReport);
-
- #if debug
- keith << "T2020RecipientReport, report contains " << fRecipientReportCount << " recipient reports." << endl;
- #endif
- keith << *this;
- }
- EXCEPTION
- {
- }
- ENDEXCEPTION;
-
- DisposeMailBuffer ( getBlockPB.buffer );
-
- MSAMClosePB closePB;
-
- closePB.mailMsgRef = openPB.mailMsgRef;
- FAILOSErr(MSAMCloseSleep((MSAMParam*) &closePB));
- }
- EXCEPTION
- {
- DeallocateHandle(fRecipientReport);
- fRecipientReport = nil;
- }
- ENDEXCEPTION
-
- }
-
- T2020RecipientReport::~T2020RecipientReport() {
-
- DisposeIfHandle (fRecipientReport);
-
- }
-
- short T2020RecipientReport::GetRecipientCount() const
- {
- return fRecipientReportCount;
- }
-
- Boolean T2020RecipientReport::GetRecipientStatus(short index, short& recipientIndex, OSErr& recipientStatus) const
- {
- unused(index);
-
- if ((index >= 1) && (index <= fRecipientReportCount)) {
- OCERecipientReport* report = (OCERecipientReport *) (*fRecipientReport + sizeof(OCERecipientReport));
-
- recipientIndex = report[index].rcptIndex;
- recipientStatus = report[index].result;
- return true;
- }
-
- recipientIndex = 0;
- recipientStatus = noErr;
- return false;
- }
-
- ostream& T2020RecipientReport::operator >> ( ostream& outStream ) const
- {
- IPMReportBlockHeader* headerP = (IPMReportBlockHeader*) (*fRecipientReport);
-
- outStream << "T2020RecipientReport: msgID=" << headerP ->msgID << " creationTime=" << headerP->creationTime << endl;
- outStream << " Contains " << GetRecipientCount() << " recipients." << endl;
- for (short index = 1; index <= GetRecipientCount(); ++index) {
- short recipientIndex;
- OSErr status;
-
- outStream << " " << index << ". ";
- if (GetRecipientStatus(index, recipientIndex, status)) {
- outStream << " recIndex=" << recipientIndex << " status=" << status;
- } else {
- outStream << " not present";
- }
- outStream << flush << endl;
- }
-
- return outStream;
- }
-